package xinya.com.baselibrary.bean.program;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.converter.PropertyConverter;

import java.util.List;

import xinya.com.baselibrary.utils.gson.GenericType;
import xinya.com.baselibrary.utils.gson.GsonUtils;

@Entity
public class SceneBean {
    /**
     * background : #ffffff
     * created_at : 2019-06-18 21:48:37
     * duration :
     * id : 3
     * name :
     * serial : 1
     * updated_at : 2019-06-18 21:48:37
     */

    private String background;
    private String created_at;
    private String duration;
    @Id
    private long id;
    private String name;
    private int serial;
    private String updated_at;
    private boolean downloadComplete;
    private float width;
    private float height;
    private int screen01;
    private int screen02;
    @Convert(converter = PositionBeanConverter.class, columnType = String.class)
    private List<PositionBean> positionBeans;

    @Generated(hash = 2129146712)
    public SceneBean(String background, String created_at, String duration, long id, String name, int serial, String updated_at,
            boolean downloadComplete, float width, float height, int screen01, int screen02, List<PositionBean> positionBeans) {
        this.background = background;
        this.created_at = created_at;
        this.duration = duration;
        this.id = id;
        this.name = name;
        this.serial = serial;
        this.updated_at = updated_at;
        this.downloadComplete = downloadComplete;
        this.width = width;
        this.height = height;
        this.screen01 = screen01;
        this.screen02 = screen02;
        this.positionBeans = positionBeans;
    }

    @Generated(hash = 418765892)
    public SceneBean() {
    }

    public String getBackground() {
        return this.background;
    }

    public void setBackground(String background) {
        this.background = background;
    }

    public String getCreated_at() {
        return this.created_at;
    }

    public void setCreated_at(String created_at) {
        this.created_at = created_at;
    }

    public String getDuration() {
        return this.duration;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    public long getId() {
        return this.id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSerial() {
        return this.serial;
    }

    public void setSerial(int serial) {
        this.serial = serial;
    }

    public String getUpdated_at() {
        return this.updated_at;
    }

    public void setUpdated_at(String updated_at) {
        this.updated_at = updated_at;
    }

    public boolean getDownloadComplete() {
        return this.downloadComplete;
    }

    public void setDownloadComplete(boolean downloadComplete) {
        this.downloadComplete = downloadComplete;
    }

    public float getWidth() {
        return this.width;
    }

    public void setWidth(float width) {
        this.width = width;
    }

    public float getHeight() {
        return this.height;
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public int getScreen01() {
        return this.screen01;
    }

    public void setScreen01(int screen01) {
        this.screen01 = screen01;
    }

    public int getScreen02() {
        return this.screen02;
    }

    public void setScreen02(int screen02) {
        this.screen02 = screen02;
    }

    public List<PositionBean> getPositionBeans() {
        return this.positionBeans;
    }

    public void setPositionBeans(List<PositionBean> positionBeans) {
        this.positionBeans = positionBeans;
    }

    public static class PositionBeanConverter implements PropertyConverter<List<PositionBean>, String> {
        @Override
        public List<PositionBean> convertToEntityProperty(String databaseValue) {
            if (databaseValue == null) {
                return null;
            }
            List<PositionBean> positionBeans = GsonUtils.parseToGenericObject(databaseValue, new GenericType<List<PositionBean>>() {
            });
            return positionBeans;
        }

        @Override
        public String convertToDatabaseValue(List<PositionBean> entityProperty) {
            if (entityProperty == null) {
                return null;
            }
            return GsonUtils.parseObject(entityProperty);
        }
    }
}